//
// Created by wujehy on 2020/8/4.
//

#ifndef AUTH_RAFT_DAOMANAGER_H
#define AUTH_RAFT_DAOMANAGER_H

#include "baseType.h"
#include <SQLiteCpp/Database.h>

class DaoManager : public ManagerBase
{
//    NetWorkWarpper *netWorkWarpper = nullptr;
    // 分库
    SQLite::Database *user_database = nullptr;
    SQLite::Database *iot_database = nullptr;

    void registerDB();

    std::map<int, DaoBase<void, SQLite::Database> *> m_dao_map;
public:
    Type type() override;

    void init() override;

//    void setNetWorkWarpper(NetWorkWarpper *netWorkWarpper);

    template<class T>
    T *getTable(int type_)
    {
        auto find = m_dao_map.find( type_ );
        if (find->first == type_)
        {
            return (T *) find->second;
        } else
        {
            return nullptr;
        }
    }

    virtual ~DaoManager();

    void init_finished() override;
};


#endif //AUTH_RAFT_DAOMANAGER_H
